window.onload = function(){
	//点击返回收支明细
	var close = document.querySelector(".close");
	close.addEventListener("click",function(){
		history.back();
	})
	
	//获取本地存储信息
	var obj = JSON.parse(localStorage.getItem('details'));
	console.log(obj);
	console.log(obj.money);
	//动态修改页面内容
	var moneySum = document.querySelector(".moneySum");
	var classify = document.querySelector(".classify");
	var payTime = document.querySelector(".payTime");
	var payWay = document.querySelector(".payway");
	function editInfo(){
		//金额
		moneySum.innerText = isAddMoney();
		//类型
		classify.innerText = obj.title;
		//时间
		payTime.innerHTML = `<span>${obj.day}</span>
							<span>${obj.time}</span>`;
		//支付渠道
		payWay.innerText = obj.way;
	}
	editInfo();
	//判断支出还是收入，并修改金额颜色，去掉正负号
	function isAddMoney(){
		var m = obj.money;
		var howMoney = document.querySelector(".howMoney");
		if(m.charAt(0)=="+"){
			moneySum.classList.add("positiveColor");
			howMoney.innerText="收入金额";
		}else if(m.charAt(0)=="-") {
			moneySum.classList.add("negativeColor");
			howMoney.innerText="支付金额";
		}
		m = m.slice(1);
		return m;
	}
}
